package Structure.array;

import java.util.Arrays;
import java.util.Random;

/**
 * @author wang'ji'cheng
 * @date 2025/7/26
 */
public class ArrayDemo6 {
    /**
     * 定义一个数组，初始值为1,2,3,4,5
     * 随机打乱顺序 eg:5,2,3,4,1
     */
    public static void main(String[] args) {
        int [] arr = {1,2,3,4,5};
        Random rand = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rand.nextInt(arr.length);
            int temp = arr[i];
            arr[i]=arr[r];
            arr[r]=temp;
        }
        System.out.println(Arrays.toString(arr));
    }
}
